package com.kehutong.work.order.manage.admin;

import org.coraframework.authz.HasPermission;
import org.coraframework.inject.Inject;
import org.coraframework.json.JSONObject;
import org.coraframework.mvc.MvcAction;
import org.coraframework.mvc.http.Bean;
import org.coraframework.mvc.http.ReqMapping;
import org.coraframework.mvc.http.result.Result;
import com.kehutong.work.order.manage.entity.WorkOrderManageType;
import com.kehutong.work.order.manage.service.WorkOrderTypeService;

/**
 * 管理后台-工单管理-类型管理
 */
@MvcAction
@ReqMapping("/admin/work/order/manage/type")
public class WorkOrderTypeController {

    @Inject
    private WorkOrderTypeService typeService;

    @HasPermission("work:order:manage:type:view")
    @ReqMapping("/list/page")
    public Object listPage(JSONObject jsonObject) {
        return typeService.listPage(jsonObject);
    }

    @ReqMapping("/list")
    public Object list(JSONObject jsonObject) {
        return typeService.list(jsonObject);
    }

    @HasPermission("work:order:manage:type:add")
    @Bean(newInstance=true, copy=true)
    @ReqMapping("/save")
    public Object save(WorkOrderManageType type) {

        return typeService.save(type);
    }

    @HasPermission("work:order:manage:type:edit")
    @Bean(copy=true)
    @ReqMapping("/update")
    public Object update(WorkOrderManageType type) {

        return typeService.update(type);
    }

    @HasPermission("work:order:manage:type:del")
    @ReqMapping("/delete")
    public Object delete(WorkOrderManageType type) throws Exception {

        return typeService.delete(type);
    }

    @HasPermission("work:order:manage:type:edit")
    @Bean(copy=true)
    @ReqMapping("/updateSort")
    public Object updateSort(WorkOrderManageType type, Integer sort) throws Exception {

        return typeService.updateSort(type, sort);
    }

    @ReqMapping("/get")
    public Object get(WorkOrderManageType type) {

        return Result.success(type);
    }
}
